//
//  PywBindGetSMSCodeController.m
//  PywSdk
//
//  Created by Jade on 16/8/30.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "PywBindGetSMSCodeController.h"
#import "PywBindVerifyCodeController.h"
#import "PywGetSMSCodeView.h"
#import "PywGetSmsCodeApi.h"
#import "PywMasonry.h"
#import "PywBuriedManager.h"

@interface PywBindGetSMSCodeController ()
@property (nonatomic,strong) PywGetSMSCodeView *getSMSCodeView;
@end

@implementation PywBindGetSMSCodeController
KeyBoardHelper(90)


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setUp];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSLog(@"%s",__FUNCTION__);
    [PywBuriedManager manager].page_sn = @"4";
    [[PywBuriedManager manager] saveUserActionDataWithPageSn:@"4" actionSn:@"1" typeSn:@"1"];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    NSLog(@"%s",__FUNCTION__);
    [PywBuriedManager manager].page_sn = @"";
//    [[PywBuriedManager manager] saveUserActionDataWithPageSn:@"4" actionSn:@"2" typeSn:@"2"];
}

- (void)returnback
{
    [super returnback];
    [[PywBuriedManager manager] saveUserActionDataWithPageSn:@"4" actionSn:@"7" typeSn:@"3"];
}

#pragma mark - setUp
- (void)setUp
{
    self.title = @"绑定手机";
    self.navigationItem.rightBarButtonItem = nil;
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:self.getSMSCodeView];
    [self.getSMSCodeView mas_makeConstraints:^(PywMASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
}

#pragma mark - getter
- (PywGetSMSCodeView *)getSMSCodeView
{
    if (!_getSMSCodeView) {
        _getSMSCodeView = [[PywGetSMSCodeView alloc] initWithSmsType:SMSCODETYPE_BUNDLE_PASSPORT];
        WEAK_SELF;
        _getSMSCodeView.getSmsCodeComplete = ^(NSString *status,NSString *smsType,NSString *phoneNum) {
            [weakSelf skipVerifySmsCodeView:status
                                    smsType:smsType
                                   phoneNum:phoneNum];
        };
    }
    return _getSMSCodeView;
}

#pragma mark - Actions
- (void)skipVerifySmsCodeView:(NSString *)status
                      smsType:(NSString *)smsType
                     phoneNum:(NSString *)phoneNum
{
    // 跳转控制器
    PywBindVerifyCodeController *verifyCodeView = [[PywBindVerifyCodeController alloc] initWithStatus:status
                                                                                             phoneNum:phoneNum
                                                                                              smsType:smsType];
    [self.navigationController pushViewController:verifyCodeView animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
